<?php
namespace app\service;
use think\facade\Db;
class propertyService{
     //查询指定ID费用类型信息
    public function costtypeId($id){
        return Db::name('costtype')->where('id',$id)->find();
    }
    //修改指定ID费用类型信息
    public function costtypeUpdate($data){
		return Db::name('costtype')->update($data);
    }
    //添加费用类型
    public function costtypeAdd($data){
        return Db::name('costtype')->insert($data);
    }
    public function costName($type,$property_id){
        return Db::name('costtype')->where('type',$type)->where('property_id',$property_id)->find();
    }
    public function costListWhere($where,$property_id){
        return Db::name('costtype')->where("property_id","in",$property_id)->where($where)->order('id asc')->select();
    }
    public function costNumberWhere($where,$property_id){
        return Db::name('costtype')->where("property_id","in",$property_id)->where($where)->count();
    }
    
    //查询物业数据
    public function propertyList($where){
        return Db::name('property')->where($where)->order('id asc')->paginate(20);
    }
    //查询物业条数
    public function propertyNumber($where){
        return Db::name('property')->where($where)->count();
    }
    //查询指定ID服务商名称
    public function propertyIdName($id){
        return Db::name('service')->where('id',$id)->find();
    }

    public function getZftInfo($id){
        return Db::name('property_zftset')->where('property_id',$id)->find();
    }
    //查询服务商信息
    public function serviceList($where){
        return Db::name('service')->where($where)->order('id asc')->select();
    }
    //查询物业是否已添加
    public function propertyName($name){
        return Db::name('property')->where('name',$name)->find();
    }
    //添加物业
    public function propertyAdd($data){
        return Db::name('property')->insert($data);
    }
    //查询指定ID物业信息
    public function propertyId($id){
        return Db::name('property')->where('id',$id)->find();
    }
    //修改指定ID物业信息
    public function propertyUpdate($data){
		return Db::name('property')->update($data);
    }

    public function propertyZftByCommunityId($community_id){
        $property_id=Db::name('community')->where('community_id',$community_id)->value("property_id");//;

        $propertyZft=Db::name('property_zftset')->where('property_id',$property_id)->find();
        return $propertyZft;
    }
    public function propertyZftByComId($com_id){
        $property_id=Db::name('community')->where('id',$com_id)->value("property_id");//;

        $propertyZft=Db::name('property_zftset')->where('property_id',$property_id)->find();
        return $propertyZft;
    }
}